// 图片上传至本地服务器
$(function () {
    var uploadBtn = $("#upload-file");
    uploadBtn.change(function (event) {
        event.preventDefault();
        var file = this.files[0];
        if (file === 'undefined') {
            return xfzalert.alertError('没有上次任何文件!')
        }
        ;
        formData = new FormData();
        formData.append('file', file);


        xfzajax.post({
            // 'url': '/cms/upload_file/',  // 文件上传至本地服务器
            'url': '/cms/aliOOS/',          // 文件上传至阿里云服务器
            'data': formData,
            'processData': false,  // tell jquery not to process the data
            'contentType': false,  // tell jquery not to set contentType
            'success': function (result) {
                if (result['code'] === 200) {
                    console.log(result);
                    var url = result['data']['url'];
                    var thumbnailInput = $("input[name='thumbnail']");
                    thumbnailInput.val(url);
                }else{
                    var message = result['message'];
                    window.messageBox.showError(message);
                }
            }
        });
    });
});